<?php
namespace Admin\Controller;
use Think\Controller;
class CommonController extends Controller {
	
    //利用钩子来判断是否登录
    public function _initialize(){

        if(!empty($_SESSION['admin'])){
              $node_con = $_SESSION['node_con'];
              $node_act = $_SESSION['node_act'];
               //判断控制器和方法是否存在
              $con = strtolower(CONTROLLER_NAME);
              $act = strtolower(ACTION_NAME);
              
              //检测是否权限
              if(!in_array($con,$node_con) || !in_array($act,$node_act)){
                       $this->error('没有权限');         
              }           
 
        }else{
            $this->redirect('admin/login/login');
        }
      	
    }
}